package com.cennavi.funcs;

import java.util.ArrayList;

import org.apache.spark.api.java.function.PairFlatMapFunction;

import scala.Tuple2;

/** * @author  作者 :allen
    * @date 创建时间：2017年9月28日 上午11:07:57 
    * @version 1.0 
    */

public class SplitPairFlatMapFunction
		implements PairFlatMapFunction<Tuple2<String, String>, String, String> {

	private static final long serialVersionUID = 1L;

	public Iterable<Tuple2<String, String>> call(Tuple2<String, String> arg0) throws Exception {
		ArrayList<Tuple2<String, String>> returnList = new ArrayList<Tuple2<String, String>>();
		if(null != arg0){
			String time = arg0._1;
			String[] data = arg0._2.split("\\|");
			for(int i=0;i < data.length;i ++){
				returnList.add(new Tuple2<String, String>(time, data[i]));
			}
			return returnList;
		}else{
			return null;
		}
//		String time = arg0._1;
//		if(DateUtil.isIntegral5min(time)){
//			String[] data = arg0._2.split("\\|");
//			for(int i=0;i < data.length;i ++){
//				returnList.add(new Tuple2<String, String>(time, data[i]));
//			}
//			return returnList;
//		}else{
//			return null;
//		}
		
	}

}
